﻿using Microsoft.AspNetCore.Mvc;
using System.Diagnostics.CodeAnalysis;

namespace Swimj.AspNetCore.Mvc
{
    public class CustomFileResult : IActionResult
    {
        public CustomFileResult(Stream? fileStream, string? fileName)
        {
            FileStream = fileStream;
            FileName = fileName;
        }

        [NotNull]
        public Stream? FileStream { get; set; }

        [NotNull]
        public string? FileName { get; set; }

        public async Task ExecuteResultAsync(ActionContext context)
        {
            var executor = new CustomFileResultExecutor();
            await executor.ExecuteAsync(context, this);
        }
    }
}
